import java.io.*;
import java.util.*;

public class PasswdFileLoader  {

    private Hashtable psHashTable = null;
    private File name = null;

    public void setFileName( String file_name )
    {
	name = new File (file_name);
    }

    public Hashtable getHashTable () {
	return psHashTable;
    }

    public void setFileName( File file )
    {
	name = file;
    }

    public void loadFile () {

        if ( !name.exists() ) {
	    System.out.println("File:"+name.getName()+" not found!");

	    return;
	}

	if ( name.isFile() ) {
	   try {
               RandomAccessFile r =  new RandomAccessFile( name, "r" );
               String text;
	       String user;
	       String passwd;
	       psHashTable = new Hashtable ();
               while( ( text = r.readLine() ) != null ) {
		   StringTokenizer tokens = new StringTokenizer(text, ":");
		   while (tokens.hasMoreTokens()) {
		       user   = (String)tokens.nextToken();
		       passwd = (String)tokens.nextToken();
		       psHashTable.put(user, passwd);
		   }
	       }
	       System.out.println(psHashTable);
	       r.close();
	   }
	   catch( IOException e ) {

	   }
       }
    }

    public Hashtable getHashtable () {
	return  psHashTable;
    }
    public static void main (String args[]) {
	PasswdFileLoader ps_loader = new PasswdFileLoader();
	ps_loader.setFileName(new File("C:/ApacheGroup/Apache2", ".htaccess"));
	ps_loader.loadFile();
    }
}





